package com.steak.bootactivemq.controller;

import com.steak.bootactivemq.entity.Opt;
import com.steak.bootactivemq.service.OptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.*;

//案例：在发送注册信息后立即响应给用户，而不要将注册数据加入到数据后才响应用户
@RestController
public class OptController {

    @Autowired
    JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private JmsTemplate jmsTemplate;

    @Autowired
    private Queue queue;


    @GetMapping("/opt")
    public String send(Opt opt) throws JMSException {
        jmsMessagingTemplate.convertAndSend(queue,opt);
        return "注册成功";
    }
}
